The buf_t is used internally in IRIX by the paging I/O system to manage queues of physical pages, and by filesystems to manage queues of pages of file data. The paging system and filesystems are the primary clients of the pfxstrategy() entry point to a block device driver, so it is only natural that a buf_t pointer is the input argument to pfxstrategy().
Tip: The idbg kernel debugging tool has several functions related to displaying the contents of buf_t objects. See "Commands to Display buf_t Objects".
Because buf_t is used by so many software components, it has many fields that are not relevant to device driver needs, as well as some fields that have multiple uses. The relevant fields include the following:
b_edev | dev_t giving device major and minor numbers. |
b_flags | Operational flags; for a detailed list see buf(D4). |
b_forw, b_back, av_forw, av_back | Queuing pointers, available for driver use within the pfxstrategy() routine. |
b_un.b_addr | Sometimes the kernel virtual address of the buffer, depending on the b_flags setting BP_ISMAPPED. |
b_bcount | Number of bytes to transfer. |
b_blkno | Starting logical block number on device. |
b_iodone | Address of a driver internal function to be called on I/O completion. |
b_resid | Number of bytes not transferred, set at completion to 0 unless an error occurs. |
b_error | Error code, set at completion of I/O. |
The pfxstrategy() routine may have to translate the logical block number based on the driver's information about device partitioning and device geometry (sector size, sectors per track, tracks per cylinder).
When the macro BP_ISMAPPED(buf_t-address) returns true, the buffer is in kernel virtual memory and its virtual address is in b_un.b_addr.
When BP_ISMAPPED(buf_t-address) returns false, the buffer is described by a chain of pfdat structures (declared in sys/pfdat.h, but containing no fields of any use to a device driver). In this case, b_un.b_addr contains only an offset into the first page frame of the chain. See "Managing Buffer Virtual Addresses" for a method of mapping an unmapped buffer.